<template>
	<view :class="currentTheme">
		<a-nabbar name="门店类型" />
		<view class="u-padding-32">
			<select-items :item="list" v-if="showTagList" v-model="checked" :maxChecked="5"></select-items>
		</view>
		<fixed-team btnText="保存设置" @btnClick="save"></fixed-team>
	</view>
</template>

<script>
	import selectItems from '@/components/selectArr/selectArr.vue'
	export default {
		components: {
			selectItems
		},
		data() {
			return {
				checked:[],
				loading:false,
				list:{},
				showTagList:false
			};
		},
		onLoad(option) {
			this.$store.dispatch('getClassify').then(res=>{
				this.list = res.find(val=>val.label=='门店类型') || {};
				if(option.storeType){
					const tags = option.storeType.split(',');
					if(tags.length){
						this.checked = tags.map(val=>{
							return this.list.children.find(item=>item.cateName===val).id;
						})
						console.log(this.checked)
					}
				}
				this.showTagList = true;
			})
		},
		methods: {
			save() {
				const getChecked = this.checked.map(val=>{
					return this.list.children.find(item=>item.id===val).cateName;
				}).join(',')
				uni.$emit('setTag',getChecked)
				this.$u.route({type:'back'})
			}
		},
	}
</script>

<style lang="scss">

</style>
